home *** CD-ROM | disk | FTP | other *** search
- Path: magnus.acs.ohio-state.edu!news
- From: Angela Mallett <mallett@cfm.ohio-state.edu>
- Newsgroups: comp.lang.c++
- Subject: Problem reading int from stream using fill character
- Date: 16 Feb 1996 18:37:58 GMT
- Organization: Center for Mapping
- Message-ID: <4g2iu6$dag@charm.magnus.acs.ohio-state.edu>
- NNTP-Posting-Host: nicolosi.cfm.ohio-state.edu
- Mime-Version: 1.0
- Content-Type: text/plain; charset=us-ascii
- Content-Transfer-Encoding: 7bit
- X-Mailer: Mozilla 1.22 (Windows; I; 16bit)
-
- I am reading formatted IO, in which a '0' character is used as a fill character
- to pad integers. The problem I am having is shown in the example below. I can
- get round the problem reading as e.g. doubles and casting, but I am interested
- if there is a better way. Thank you.
- [using Borland C++ v4.5, Windows 3.1]
-
-
- #include <strstrea.h>
-
- int main()
- {
- char buffer[] = {"10 09 23"};
- int a=0, b=0, c=0;
-
- istrstream isstr(buffer);
- isstr >> a >> b >> c;
-
- cout << a << ' ' << b << ' ' << c << endl; //OUTPUT: 10 0 9!
-
- return 0;
- }
-
- --
- Angela Mallett <mallett@cfm.ohio-state.edu>
- 1216 Kinnear Road, Columbus, Ohio 43212
- phone: 614-688-3420 fax: 614-292-8062
-
-
-